package com.cn.intelligence.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cn.intelligence.mapper.AreasMapper;
import com.cn.intelligence.mapper.CitiesMapper;
import com.cn.intelligence.mapper.MemberMapper;
import com.cn.intelligence.mapper.ProvincesMapper;
import com.cn.intelligence.mapper.TbCartMapper;
import com.cn.intelligence.mapper.TbUserMapper;
import com.cn.intelligence.mapper.WuliuMapper;
import com.cn.intelligence.pojo.Areas;
import com.cn.intelligence.pojo.AreasExample;
import com.cn.intelligence.pojo.Cities;
import com.cn.intelligence.pojo.CitiesExample;
import com.cn.intelligence.pojo.Member;
import com.cn.intelligence.pojo.MemberExample;
import com.cn.intelligence.pojo.Provinces;
import com.cn.intelligence.pojo.ProvincesExample;
import com.cn.intelligence.pojo.TbUser;
import com.cn.intelligence.pojo.TbUserExample;
import com.cn.intelligence.pojo.Wuliu;
import com.cn.intelligence.pojo.WuliuExample;
import com.cn.intelligence.service.CommonService;
@Service
public class CommonServiceImpl implements CommonService {

	@Autowired
	private ProvincesMapper provincesMapper;
	@Autowired
	private CitiesMapper citiesMapper;
	@Autowired
	private AreasMapper areasMapper;
	@Autowired
	private WuliuMapper wuliuMapper;
	@Autowired
	private TbUserMapper tbUserMapper;
	@Autowired
	public MemberMapper memberMapper;

	@Override
	public List<Provinces>  selectProvinces(String name, String provinceId) {
		
		ProvincesExample provincesExample = new ProvincesExample();
		ProvincesExample.Criteria criteria = provincesExample.createCriteria();
		
		if(name!=null && !"".equals(name)){
			criteria.andProvinceLike(name);
		}
		if(provinceId!=null && !"".equals(provinceId)){
			criteria.andProvinceidEqualTo(provinceId);
		}
		 List<Provinces>  list = provincesMapper.selectByExample(provincesExample);
		return list;
	}

	@Override
	public List<Cities> selectCities(String name, String provinceId) {
		
		CitiesExample citiesExample = new CitiesExample();
		CitiesExample.Criteria criteria = citiesExample.createCriteria();
		
		if(name!=null && !"".equals(name)){
			criteria.andCityLike(name);
		}
		if(provinceId!=null && !"".equals(provinceId)){
			criteria.andProvinceidEqualTo(provinceId);
		}
		 List<Cities>  list = citiesMapper.selectByExample(citiesExample);
		return list;
	}

	@Override
	public List<Areas> selectAreas(String name, String cityId) {
		
		AreasExample areasExample = new AreasExample();
		AreasExample.Criteria criteria = areasExample.createCriteria();
		
		if(name!=null && !"".equals(name)){
			criteria.andAreaLike(name);
		}
		if(cityId!=null && !"".equals(cityId)){
			criteria.andCityidEqualTo(cityId);
		}
		 List<Areas>  list = areasMapper.selectByExample(areasExample);
		return list;
	}

	@Override
	public List<Wuliu> selectgetWuLius() {
		
		WuliuExample wuliuExample = new WuliuExample();
		 List<Wuliu>  list = wuliuMapper.selectByExample(wuliuExample);
		return list;
	}

	@Override
	public List<TbUser> selectgetCususer() {
		
		TbUserExample tbUserExample = new TbUserExample();
		List<TbUser>  list = tbUserMapper.selectByExample(tbUserExample);
		return list;
	}

	@Override
	public List<Member> getMemberforLerevel() {
		MemberExample memberExample = new MemberExample();
		MemberExample.Criteria criteria = memberExample.createCriteria();
		criteria.andIsParentEqualTo(true);
		List<Member>  list = memberMapper.selectByExample(memberExample);
		return list;
	}

}
